/*
 * @lc app=leetcode id=470 lang=cpp
 *
 * [470] Implement Rand10() Using Rand7()
 */

// @lc code=start
// The rand7() API is already defined for you.
// int rand7();
// @return a random integer in the range 1 to 7

class Solution {
public:
    int rand10() {
        int n = rand7() ;
        while (n == 7) {
            n = rand7();
        }
        int i = rand7();
        while (i > 5) {
            i = rand7();
        }
        return i + (n & 1 ? 5 : 0);

    }
};
// @lc code=end

